package com.cmrx.model.task;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.cmrx.model.service.SysdictService;


@Component
public class ChartTask {
    private static final Logger log = LoggerFactory.getLogger(ChartTask.class);

    //	@Scheduled(cron = "0 25 9 ? * *")
    //    public void serviceOrderTask() {
    //        Date date = new Date();
    //        SimpleDateFormat sdf = new SimpleDateFormat("YY:MM:DD hh:mm:ss");
    //        String formatDataStr = sdf.format(date);
    //        System.out.println("|_"+formatDataStr);
    //    }


    //	  @Scheduled(cron = "0/5 * * * * *")
    //	    public void scheduled(){
    //	        log.info("=====>>>>>使用cron  {}",System.currentTimeMillis());
    //	    }
	/*
	 * @Scheduled(cron = "0 0 23 ? * *") public void loadUsers() { try {
	 * SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); String
	 * time = sdf.format(new Date()); System.out.println("11:"+time);
	 * //System.out.println(signLogin.size()); b } catch (Exception e) { // TODO:
	 * handle exception e.printStackTrace(); } }
	 */
    
    @Autowired
    private SysdictService sysdictService;
    
    @Scheduled(fixedRate=1000*3600*24)
    public void caseType() {
    	try {
    		sysdictService.dingshiCaseType();
            System.out.println("用户的主目录:\n"+System.getProperty("user.home"));
            System.out.println("user.dir:\n"+System.getProperty("user.dir"));
            System.out.println("案件类别成功");
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
    }
    @Scheduled(fixedRate=1000*3600*23)
    public void gxsdm() {
    	try {
    		sysdictService.dingshigxsdm();
    		System.out.println("区划缓存成功");
    	} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
    }
    @Scheduled(cron = "0 30 23 ? * *")
    public void sixCaseType() {
    	try {
    		sysdictService.dingshiSixCaseType();
    		System.out.println("6类案件缓存成功");
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
    }
    
    @Scheduled(cron = "0 0 23 ? * *")
    public void sixSysidct() {
    	try {
    		String rootKey = "XCFXYJZLDM";
    		sysdictService.dingshiSysdict(rootKey);
    		rootKey = "XZDXFLDM";
    		sysdictService.dingshiSysdict(rootKey);
    		rootKey = "XZCSFLDM";
    		sysdictService.dingshiSysdict(rootKey);
    		rootKey = "ZASJDFLDM";
    		sysdictService.dingshiSysdict(rootKey);
    		rootKey = "ZACRKDM";
    		sysdictService.dingshiSysdict(rootKey);
    		rootKey = "ZASDFLDM";
    		sysdictService.dingshiSysdict(rootKey);
    		rootKey = "QRFSFLDM";
    		sysdictService.dingshiSysdict(rootKey);
    		rootKey = "ZATDFLDM";
    		sysdictService.dingshiSysdict(rootKey);
    		rootKey = "AJXZDM";
    		sysdictService.dingshiSysdict(rootKey);
    		rootKey = "ZADJMDDM";
    		sysdictService.dingshiSysdict(rootKey);
    		rootKey = "ZAGJLYDM";
    		sysdictService.dingshiSysdict(rootKey);
    		rootKey = "ZAGJLMDM";
    		sysdictService.dingshiSysdict(rootKey);
    		System.out.println("sysdict缓存成功");
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
    }
}
